<template>
	<view class="" :style="[AppSkinVar]">
		<e-tabs :list="[{
						name: $t('common.全部'),
					},
					{
						name: $t('spellgroup.待成团'),
					},
					{
						name: $t('spellgroup.拼团成功'),
					},
					{
						name: $t('spellgroup.拼团失败'),
					}
				]" @click="click" :lineColor="AppSkin.primary" :activeStyle="{
        fontWeight: 'bold',
    }"></e-tabs>
		<view class="" v-if="groupList.length">
			<scroll-view class="scroll-box" scroll-y @scrolltolower="getData" lower-threshold="60">
				<view class="e-p-20">
					<view class="spell-group-item e-m-b-20" v-for="item in groupList" :key="item.id">
						<view class="e-flex e-p-20">
							<load-image mode="aspectFit" :size="['212rpx']" radius="40rpx"
								:src="item.skuCoverImg"></load-image>
							<view class="e-p-l-34">
								<view class="c-333 e-font-28 e-line-2 e-m-b-20">
									{{item.skuSpec}}
								</view>
								<view class="e-m-b-32 e-font-24 group-count"
									:style="{color: AppSkin.primary,backgroundColor: collageTextBackgroundColor}">
									{{item.count}}{{$t('spellgroup.pg')}}
								</view>
								<view class="e-flex justify-between" :style="{color: AppSkin.primary}">
									<view class="e-flex">
										<text class="e-font-24">{{$unitEn}}</text>
										<text class="e-font-32">{{item.price}}</text>
									</view>
									<view class="e-font-28">
										{{getState(item.state)}}
									</view>
								</view>
							</view>
						</view>
						<view class="e-flex justify-between e-p-20" v-if="item.state === 1">
							<view class="e-flex e-font-24" :style="{color: AppSkin.primary}">
								<text>{{$t('spellgroup.toTheEnd')}}: </text>
								<view class="">
									23:59:59
								</view>
							</view>
							<view class="invite-btn c-white e-font-26" :style="{background: AppSkin.primary}">
								{{$t('spellgroup.inviteNow')}}
							</view>
						</view>
					</view>
				</view>
			</scroll-view>
		</view>
		<view class="empty-box" v-else>
			<image :src="$staticPath('empty-group.png')" mode="" class="empty-img"></image>
			<text class="">{{$t('spellgroup.暂无拼团')}}</text>
		</view>
	</view>
</template>

<script setup lang="ts">
	import { ref, computed } from 'vue'
	import {
		useInit
	} from '@/common/stores'
	import {
		storeToRefs
	} from 'pinia'
	import { useCurrentInstance } from '@/common/hooks'

	const ctx = useCurrentInstance()

	const { AppSkin } = storeToRefs(useInit())
	const groupList = ref([
		{
			id: 1,
			skuCoverImg: "file/20221123/166918953158200987.jpg",
			skuSpec: "水莲花 大闸蟹螃蟹鲜活现货 公蟹3.3-3.5两 母水莲花 大闸蟹螃蟹鲜活现货 公蟹3.3-3.5两 母",
			count: 2,
			price: 119,
			state: 1
		}, {
			id: 2,
			skuCoverImg: "file/20221123/166918953158200987.jpg",
			skuSpec: "水莲花 大闸蟹螃蟹鲜活现货 公蟹3.3-3.5两 母水莲花 大闸蟹螃蟹鲜活现货 公蟹3.3-3.5两 母",
			count: 3,
			price: 120,
			state: 2
		}
	])

	const collageTextBackgroundColor = computed(() => AppSkin.primary.replace('1)', '0.05)'))
	const getState = (val : number) => {
		switch (val) {
			case 1:
				return ctx.$t('spellgroup.待成团')
			case 2:
				return ctx.$t('spellgroup.拼团成功')
			case 3:
				return ctx.$t('spellgroup.拼团失败')

		}
		return ''
	}
	const click = () => {

	}
	const getData = () => {

	}
</script>

<style lang="scss" scoped>
	.empty-box {
		height: calc(100vh - 44px);
		display: flex;
		align-items: center;
		justify-content: center;
		flex-direction: column;
		color: #989898;
		font-size: 28rpx;

		.empty-img {
			width: 400rpx;
			height: 234rpx;
		}
	}

	.scroll-box {
		height: calc(100vh - 44px);
	}


	.spell-group-item {
		background: #FFFFFF;
		border-radius: 20rpx
	}

	.group-count {
		padding: 2rpx 20rpx;
		display: inline-block;
	}

	.invite-btn {
		padding: 8rpx 16rpx;
		border-radius: 25rpx;
	}
</style>